//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.aidong.web.controller.gc;

import com.aidong.dao.base.ConditionMap;
import com.aidong.dao.base.OrderSet;
import com.aidong.dao.base.Pagination;
import com.aidong.dao.wills.GcBespeakDao;
import com.aidong.dao.wills.GcTimeTableDao;
import com.aidong.dao.wills.PtCoachCodeDao;
import com.aidong.dao.wills.PtItemCodeDao;
import com.aidong.model.wills.GcBespeak;
import com.aidong.util.ExportXls;
import com.aidong.web.controller.member.PayController;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping({"gcBespeakQuery"})
public class GcBespeakQueryController extends PayController {
    @Resource
    GcTimeTableDao gcTimeTableDao;
    @Resource
    GcBespeakDao gcBespeakDao;
    @Resource
    PtItemCodeDao ptItemCodeDao;
    @Resource
    PtCoachCodeDao ptCoachCodeDao;

    public GcBespeakQueryController() {
    }

    @RequestMapping({"list"})
    public ModelAndView list() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        return (new ModelAndView("gc/bespeakquery/list")).addObject("bespeakStatus", this.getTypeList("bespeakStatus")).addObject("dt", sdf.format(new Date()));
    }

    @RequestMapping({"_list"})
    public ModelAndView _list(@RequestParam(value = "shopCode",required = false) String shopCode, @RequestParam(value = "cardCode",required = false) String cardCode, @RequestParam(value = "custName",required = false) String custName, @RequestParam(value = "mobile",required = false) String mobile, @RequestParam(value = "classType",required = false) String classType, @RequestParam(value = "coachCode",required = false) String coachCode, @RequestParam(value = "status",required = false) Integer status, @RequestParam(value = "dateType",required = false) String dateType, @RequestParam(value = "dateFrom",required = false) String dateFrom, @RequestParam(value = "dateTo",required = false) String dateTo, @RequestParam(value = "pageNo",required = false) String pageNo, @RequestParam(value = "totalCount",required = false) String totalCount) {
        Pagination pg = new Pagination(1, 20);
        pg.setPage(this.parseInt(pageNo), this.parseInt(totalCount));
        ConditionMap cd = new ConditionMap();
        this.addConditionShopCode(cd, "shopCode", shopCode);
        cd.eq("status", status);
        cd.eq("classType", classType);
        cd.eq("cardCode", cardCode);
        cd.eq("custName", custName);
        cd.eq("mobile", mobile);
        cd.eq("coachCode", coachCode);
        if("3".equals(dateType)) {
            if(!this.chkNull(dateFrom)) {
                cd.ge("cancelTime", this.getDateFrom(dateFrom));
            }

            if(!this.chkNull(dateTo)) {
                cd.le("cancelTime", this.getDateTo(dateTo));
            }
        } else if("2".equals(dateType)) {
            if(!this.chkNull(dateFrom)) {
                cd.ge("clearTime", this.getDateFrom(dateFrom));
            }

            if(!this.chkNull(dateTo)) {
                cd.le("clearTime", this.getDateTo(dateTo));
            }
        } else {
            if(!this.chkNull(dateFrom)) {
                cd.ge("classTime", this.getDateFrom(dateFrom));
            }

            if(!this.chkNull(dateTo)) {
                cd.le("classTime", this.getDateTo(dateTo));
            }
        }

        this.gcBespeakDao.queryPageList(pg, cd, (new OrderSet()).asc("classTime"));
        ModelAndView mv = new ModelAndView("gc/bespeakquery/_list");
        mv.addObject("list", pg.getResultList());
        mv.addObject("pg", pg);
        mv.addObject("nowDate", new Date());
        return mv;
    }

    @RequestMapping({"expt"})
    public ModelAndView expt(@RequestParam(value = "shopCode",required = false) String shopCode, @RequestParam(value = "cardCode",required = false) String cardCode, @RequestParam(value = "custName",required = false) String custName, @RequestParam(value = "mobile",required = false) String mobile, @RequestParam(value = "classType",required = false) String classType, @RequestParam(value = "coachCode",required = false) String coachCode, @RequestParam(value = "status",required = false) Integer status, @RequestParam(value = "dateType",required = false) String dateType, @RequestParam(value = "dateFrom",required = false) String dateFrom, @RequestParam(value = "dateTo",required = false) String dateTo, HttpServletResponse response) {
        try {
            Pagination e = new Pagination(1, '\uea60');
            e.setPage(Integer.valueOf(1), Integer.valueOf(1));
            ConditionMap cd = new ConditionMap();
            this.addConditionShopCode(cd, "shopCode", shopCode);
            cd.eq("status", status);
            cd.eq("classType", classType);
            cd.eq("cardCode", cardCode);
            cd.eq("custName", custName);
            cd.eq("mobile", mobile);
            cd.eq("coachCode", coachCode);
            if("3".equals(dateType)) {
                if(!this.chkNull(dateFrom)) {
                    cd.ge("cancelTime", this.getDateFrom(dateFrom));
                }

                if(!this.chkNull(dateTo)) {
                    cd.le("cancelTime", this.getDateTo(dateTo));
                }
            } else if("2".equals(dateType)) {
                if(!this.chkNull(dateFrom)) {
                    cd.ge("clearTime", this.getDateFrom(dateFrom));
                }

                if(!this.chkNull(dateTo)) {
                    cd.le("clearTime", this.getDateTo(dateTo));
                }
            } else {
                if(!this.chkNull(dateFrom)) {
                    cd.ge("classTime", this.getDateFrom(dateFrom));
                }

                if(!this.chkNull(dateTo)) {
                    cd.le("classTime", this.getDateTo(dateTo));
                }
            }

            this.gcBespeakDao.queryPageList(e, cd, (new OrderSet()).asc("classTime"));
            ExportXls xls = new ExportXls(response, "小团操预约核销流水", "小团操预约核销流水");
            xls.addHead(new String[]{"门店编号", "门店名称", "会员号", "卡号", "会员姓名", "手机号", "类型", "课程编号", "课程名称", "教练编号", "教练姓名", "上课时间", "核销时间", "预约状态", "取消时间", "课时价格", "操作员", "流水号"});
            xls.setWidth(new int[]{10, 10, 20, 10, 10, 15, 10, 10, 30, 10, 10, 20, 20, 10, 20, 10, 15, 10});
            new SimpleDateFormat("yyyy-MM-dd");
            SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Iterator i$ = e.getResultList().iterator();

            while(i$.hasNext()) {
                GcBespeak bespeak = (GcBespeak)i$.next();
                xls.addRow(new Object[]{bespeak.getShopCode(), this.cache.getValue("shopName", bespeak.getShopCode()), bespeak.getMemberCode(), bespeak.getCardCode(), bespeak.getCustName(), bespeak.getMobile(), "1".equals(bespeak.getClassType())?"1对1":"1对多", bespeak.getPtCode(), this.cache.getValue("ptItemName", bespeak.getPtCode()), bespeak.getCoachCode(), this.cache.getValue("ptCoachName", bespeak.getCoachCode()), sdf2.format(bespeak.getClassTime()), bespeak.getClearTime() == null?"":sdf2.format(bespeak.getClearTime()), this.cache.getValue("bespeakStatus", String.valueOf(bespeak.getStatus())), bespeak.getCancelTime() == null?"":sdf2.format(bespeak.getCancelTime()), bespeak.getFactPrice(), this.nvl(bespeak.getCreateUser()) + " - " + this.nvl(this.cache.getValue("userName", bespeak.getCreateUser())), bespeak.getAutoId()});
            }

            xls.close();
            this.addUserLog("导出小团操预约核销流水", e.getResultList().size() + "条记录");
        } catch (Exception var19) {
            this.log.error("import", var19);
        }

        return null;
    }
}
